home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1-sources / sources / misc-headers / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-24  |  1.7 KB  |  68 lines  |  [TEXT/EMAC]

  1. /*
  2.  * This file is part of a Macintosh port of GNU Emacs.
  3.  * Copyright (C) 1993, 1994 Marc Parmet.  All rights reserved.
  4.  *
  5.  * GNU Emacs is distributed in the hope that it will be useful,
  6.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8.  * GNU General Public License for more details.
  9.  */
  10.  
  11. #ifndef __STDIO__
  12. #define __STDIO__
  13.  
  14. #include <Files.h>
  15. #include <string.h>
  16.  
  17. #define BUFSIZ        512
  18. #define _NFILE        16
  19.  
  20. #if defined(powerc)
  21. #pragma options align=mac68k
  22. #endif
  23.  
  24. typedef struct _iobuf {
  25.     int fd;
  26.     char flag;
  27.     char havepushback,havespec,external_base;
  28.     char pushback,err;
  29.     FSSpec spec;
  30.     unsigned char *base;
  31.     int cnt;    // When writing, the number of chars in the buffer written but not flushed.
  32.                 // When reading, the number of chars in the buffer still to read.
  33.     int buflen;    // When reading, the length of valid contents of the buffer
  34.                 // When writing, the same.
  35. } FILE;
  36.  
  37. #if defined(powerc)
  38. #pragma options align=reset
  39. #endif
  40.  
  41. FILE *_iob(int);
  42.  
  43. #define stdin  (_iob(0))
  44. #define stdout (_iob(1))
  45. #define stderr (_iob(2))
  46.  
  47. #define _READ    01
  48. #define _WRITE    02
  49. #define _AUTO    04
  50. #define EOF        (-1)
  51.  
  52. FILE *fopen(char *,char *);
  53. FILE *freopen(char *,char *,FILE *);
  54. FILE *fdopen(int,char *);
  55. void fprintf(FILE *,char *,...);
  56. void sprintf(char *,char *,...);
  57. void printf(char *,...);
  58. char *fgets(char *s,int n,FILE *fp);
  59. FILE *popen(char *name,char *mode);
  60.  
  61. #define getc(fp)    ((fp)->cnt && !(fp)->havepushback ? (fp)->base[(fp)->buflen - (fp)->cnt--] : _getc(fp))
  62. #define getchar()    getc(stdin)
  63.  
  64. #define putc(c,fp)    ((fp)->cnt < (fp)->buflen ? (fp)->base[(fp)->cnt++] = c : _putc(c,fp))
  65. #define putchar(c)    putc(c,stdout)
  66.  
  67. #endif
  68.